<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 
            这题相比最长递增子序列更为简单，因为它要求的是连续的
            ① 只需要遍历nums，如果nums[i]>nums[i-1] count++
            ② dp
              dp[i]表示以nums[i]为结尾的递增子序列的长度为dp[i]
            ②状态转移方程
              因为是连续递增，所以只需要判断前一个 if(nums[i-1]<nums[i])
              dp[i]=dp[i-1]+1

            ③初始化dp数组
                dp[i]=1 
            
                最后找出每个nums[i]的最长序列即可
            
            
            */
            var findLengthOfLCIS = function (nums) {
                /*                 let count = 1
                let result = 1
                for (let i = 1; i < nums.length; i++) {
                    if (nums[i] > nums[i - 1]) {
                        count++
                    } else {
                        count = 1
                    }
                    result = Math.max(count, result)
                }
                return result */
                let dp = new Array(nums.length).fill(1)
                for (let i = 1; i < nums.length; i++) {
                    if (nums[i] > nums[i - 1]) {
                        dp[i] = dp[i - 1] + 1
                    }
                }
                return Math.max(...dp[i])
            }
        </script>
    </body>
</html>
